package com.bw.paper.mvp.view.Activity;

import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;

import com.bw.paper.R;
import com.bw.paper.entity.BroadcastEntity;
import com.bw.paper.mvp.base.model.BaseEntity;
import com.bw.paper.mvp.base.view.BaseActivity;
import com.bw.paper.mvp.contact.LoginContract;
import com.bw.paper.mvp.di.DaggerLoginComponent;
import com.bw.paper.mvp.di.LoginModules;
import com.bw.paper.mvp.model.LoginModel;
import com.bw.paper.mvp.presenter.LoginPresenter;

public class UpdataNameActivity extends BaseActivity<LoginPresenter> implements LoginContract.LoginView {

        private ImageView backUpName;
        private EditText nickName;
        private Button checkNamenick;

        @Override
        public View addStatusView() {
                return f(R.id.updatename_ll);
        }

        @Override
        public int bindlayout() {
                return R.layout.activity_updata_name;
        }

        @Override
        public void initView() {
                backUpName = (ImageView) findViewById(R.id.back_up_name);
                nickName = (EditText) findViewById(R.id.nick_name);
                checkNamenick = (Button) findViewById(R.id.check_namenick);

                backUpName.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                                finish();
                        }
                });
                checkNamenick.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                                String s = nickName.getText().toString();
                                Intent intent = new Intent();
                                intent.setAction(BroadcastEntity.UPDATENAME);
                                intent.putExtra("username", s);
                                sendBroadcast(intent);
//                                startPage(UpUserActivity.class);
                                finish();
                        }
                });

        }

        @Override
        public void inject() {
                DaggerLoginComponent.builder().loginModules(new LoginModules(this))
                        .build().injectUpdataName(this);
        }

        @Override
        public void initData() {
         LoginPresenter loginPresenter = new LoginPresenter(new LoginModel(), this);

        }

        @Override
        public void refreshView(BaseEntity entity) {


        }
}